<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title><%= title %></title>

	<% include ../includes/head%>
</head>
<body>
<% include ../includes/header%>
	
	<div id="container-inner">
		<ul id="breadcrumb-wrapper">
        
	    	<li>
	            <a href="/">
                <ins>
				    <div class="br-left"></div>
				    <div class="br-mid">
				    	主页
				    </div><!--br-mid-->
				    <div class="br-right">
				    </div><!--br-right-->
                </ins>    
		        </a>
            </li>  
            
            <li>
	            <a href="blog.html">
                <ins>
				    <div class="br-left"></div>
				    <div class="br-mid">
				    	游记列表
				    </div><!--br-mid-->
				    <div class="br-right">
				    </div><!--br-right-->
                </ins>    
		        </a>
            </li>
            
           
            <li id="page-title">
          		游记列表
        	</li><!--page-title-->
        </ul>
        <div id="inner-border"></div>
        <div class="clear"></div>
        <div id="contentwrap-inner">
        	
			<div class="row">
			
				<table class="table table-hover table-bordered">
					<thead>
						<tr>
							<th>游记标题</th>
							
							<th>类型</th>
							<th>作者</th>
							<th>录入时间</th>
							<th>查看</th>
							<th>更新</th>
							<th>删除</th>
						</tr>
						
						<tbody>
							<% for(var i = 0; i < travels.length; i++){%>
							<tr class="item-id-<%= travels[i].id%>">
								<td>
									<%= travels[i].title%>
								</td>
								
								<td>
									<%= travels[i].type%>
								</td>
								<td>
									<%= travels[i].author%>
								</td>
								<td>
									<%= moment(travels[i].meta.createdAT).format('YYYY/MM/DD') %>
								</td>
								<td>
									<a href="../travel/<%= travels[i]._id %>">查看</a>
								</td>
								<td>
									<a href="../travelUpdate/<%= travels[i]._id %>">修改</a>
								</td>
								<td>
									<button type="button" data-id="<%= travels[i]._id%>" class="btn btn-danger del">删除</button>		
								</td>
							</tr>
							<%}%>
						</tbody>
						
					</thead>
				</table>
			</div>
			<div class="clear"></div>
        </div>		
	</div>



	<% include ../includes/footer%>
	<script>
		$(function(){
		    $('.del').click(
		        function(e){
		            var target = $(e.target);
		            var id = target.data('id');
		            var tr  = $('.item-id-'+ id);
		            $.ajax({
		                type:'DELETE',
		                url:'/admin/travelList?id='+id
		            })
		                .done(function(reaults){
		                    if(reaults.success===1){
		                        if(tr.length>0){
		                            tr.remove();
		                        }
		                    }
		                })
		        }
		    )
		})
	</script>
</body>
</html>